<?php

namespace YmPhp\Admin\Http\Controllers\Member\Level;

use YmPhp\Admin\Models\Member\MemberLevelActivateKey;
use YmPhp\Admin\Form;
use YmPhp\Admin\Grid;
use YmPhp\Admin\Show;
use YmPhp\Admin\Http\Controllers\AdminController;

class MemberLevelActivateKeyController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new MemberLevelActivateKey(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('lastts');
            $grid->column('uid');
            $grid->column('crts');
            $grid->column('upts');
            $grid->column('usets');
            $grid->column('cardnum');
            $grid->column('viptype');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();

            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');

            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new MemberLevelActivateKey(), function (Show $show) {
            $show->field('id');
            $show->field('lastts');
            $show->field('uid');
            $show->field('crts');
            $show->field('upts');
            $show->field('usets');
            $show->field('cardnum');
            $show->field('viptype');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new MemberLevelActivateKey(), function (Form $form) {
            $form->display('id');
            $form->text('lastts');
            $form->text('uid');
            $form->text('crts');
            $form->text('upts');
            $form->text('usets');
            $form->text('cardnum');
            $form->text('viptype');

            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
